// OutputDlg.cpp : implementation file
//

#include "stdafx.h"
#include "resource.h"
#include "OutputDialog.h"
#include "toolbase.h"
#ifdef _DEBUG
#undef THIS_FILE
static char BASED_CODE THIS_FILE[] = __FILE__;
#endif
extern bool isname(CString name);
// ToolBaseStr *pToolBaseStr;
IMPLEMENT_DYNCREATE(COutputDialog, CDialog)

/////////////////////////////////////////////////////////////////////////////
// COutputDialog property page

COutputDialog::COutputDialog(CWnd* pParent):CDialog(COutputDialog::IDD,pParent)
{
	//{{AFX_DATA_INIT(COutputDialog)
	m_checkoverlap = FALSE;
	m_depth = 1;
	m_dist = 1;
	m_overlap = 0;
	m_pointR = 0.1;
	m_color = 0;
	m_dire = 0;
	m_xstep = 0;
	m_realx = 0.0;
	m_realy = 0.0;
	m_checkdetail = TRUE;
	//}}AFX_DATA_INIT

}

COutputDialog::~COutputDialog()
{
}

void COutputDialog::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(COutputDialog)
	DDX_Check(pDX, IDC_CHECK_OVERLAP, m_checkoverlap);
	DDX_Text(pDX, IDC_DEPTH, m_depth);
	DDV_MinMaxDouble(pDX, m_depth, 0., 50000.);
	DDX_Text(pDX, IDC_DISTINGUISH, m_dist);
	DDV_MinMaxInt(pDX, m_dist, 1, 1000);
	DDX_Text(pDX, IDC_OVERLAP, m_overlap);
	DDV_MinMaxInt(pDX, m_overlap, 0, 100);
	DDX_Text(pDX, IDC_POINTRADIUS, m_pointR);
	DDV_MinMaxDouble(pDX, m_pointR, 0., 1000.);
	DDX_Radio(pDX, IDC_RADIO_COLORP, m_color);
	DDX_Radio(pDX, IDC_RADIO_DIRECTION, m_dire);
	DDX_Radio(pDX, IDC_RADIO_XSTEP, m_xstep);
	DDX_Text(pDX, IDC_REAL_X, m_realx);
	DDV_MinMaxDouble(pDX, m_realx, 0., 100000.);
	DDX_Text(pDX, IDC_REAL_Y, m_realy);
	DDX_Check(pDX, IDC_CHECK3, m_checkdetail);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(COutputDialog, CDialog)
	//{{AFX_MSG_MAP(COutputDialog)
	ON_BN_CLICKED(IDC_CHECK_OVERLAP, OnCheckOverlap)
	ON_BN_CLICKED(IDC_RADIO_DIST, OnRadioDist)
	ON_BN_CLICKED(IDC_RADIO_XSTEP, OnRadioXstep)
	ON_EN_CHANGE(IDC_REAL_X, OnChangeRealX)
	ON_EN_CHANGE(IDC_POINTRADIUS, OnChangePointradius)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()


/////////////////////////////////////////////////////////////////////////////
// COutputPropertyPage2 property page

void COutputDialog::OnCheckOverlap() 
{
	// TODO: Add your control notification handler code here
	m_checkoverlap=~m_checkoverlap;
	if(m_checkoverlap)
		GetDlgItem(IDC_OVERLAP)->EnableWindow(TRUE);
	else
        GetDlgItem(IDC_OVERLAP)->EnableWindow(FALSE);

}



BOOL COutputDialog::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	GetDlgItem(IDC_OVERLAP)->EnableWindow(FALSE);
	GetDlgItem(IDC_DISTINGUISH)->EnableWindow(FALSE);
	
	CString s;
	s.Format("%f",2*m_pointR);
	GetDlgItem(IDC_WIDTH)->SetWindowText(s);
	GetDlgItem(IDC_WIDTH1)->SetWindowText(s);
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void COutputDialog::OnRadioDist() 
{
	// TODO: Add your control notification handler code here
		GetDlgItem(IDC_DISTINGUISH)->EnableWindow(TRUE);
}

void COutputDialog::OnRadioXstep() 
{
	// TODO: Add your control notification handler code here
		GetDlgItem(IDC_DISTINGUISH)->EnableWindow(FALSE);
}

void COutputDialog::OnChangeRealX() 
{
	// TODO: If this is a RICHEDIT control, the control will not
	// send this notification unless you override the CDialog::OnInitDialog()
	// function and call CRichEditCtrl().SetEventMask()
	// with the ENM_CHANGE flag ORed into the mask.
	UpdateData(TRUE);
    m_realy=m_realx*xyratio;
    UpdateData(FALSE);
   
	// TODO: Add your control notification handler code here
	
}

void COutputDialog::OnChangePointradius() 
{
	// TODO: If this is a RICHEDIT control, the control will not
	// send this notification unless you override the CDialog::OnInitDialog()
	// function and call CRichEditCtrl().SetEventMask()
	// with the ENM_CHANGE flag ORed into the mask.
	UpdateData();
	CString s;
	s.Format("%f",2*m_pointR);
	GetDlgItem(IDC_WIDTH)->SetWindowText(s);
	GetDlgItem(IDC_WIDTH1)->SetWindowText(s);
	// TODO: Add your control notification handler code here
	
}
